﻿using rbac.Domain.Entity;
using rbac.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rbac.Domain.Impl
{
    public class UserRoleRepository:IUserRoleRepository
    {
        private readonly RbacContext _context;


        public UserRoleRepository(RbacContext context)
        {
            _context = context;
        }

        public IQueryable<UserRole> UserRoles()
        {
            return _context.UserRoles;
        }


        public IQueryable<Role> UserRolesByUserId(params int[] userId)
        {
            return from ur in _context.UserRoles
                   join r in _context.Roles on ur.RoleId equals r.Id
                   where userId.Contains(ur.UserId)
                   select r;
        }
    }
}
